<!DOCTYPE html>
<html lang="zh_CN" xmlns:th="http://www.thymeleaf.org">
<head th:include="include::head"></head>
<body>
<div class="layui-fluid">
    <!--form表单-->
    <form class="layui-form">

        <div class="layui-form-item">
            <label class="layui-form-label">标题</label>
            <div class="layui-input-block">
                <input type="text" name="title" autocomplete="off" class="layui-input" lay-verify="required">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">排序</label>
            <div class="layui-input-block">
                <input type="text" name="sort" autocomplete="off" class="layui-input" lay-verify="required">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">附件</label>
            <div class="layui-input-block">
                <input type="text" name="enclosure" autocomplete="off" class="layui-input" lay-verify="required">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">类别</label>
            <div class="layui-input-block">
                <select lay-filter="filter" name="type">
                    <th:block th:each="value,iterStat: ${diy['bulletin_type']}">
                        <option th:value="${value.dictionaryRoute}" th:utext="${value.dictionaryName}"></option>
                    </th:block>
                </select>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">置顶</label>
            <div class="layui-input-block">
                <th:block th:each="value,iterStat: ${diy['set_top_type']}">
                    <input th:if="${iterStat.index == 0}" type="radio" name="isSetTop" th:value="${value.dictionaryRoute}" th:title="${value.dictionaryName}"  checked  >
                    <input th:if="${iterStat.index != 0}" type="radio" name="isSetTop" th:value="${value.dictionaryRoute}" th:title="${value.dictionaryName}">
                </th:block>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">状态</label>
            <div class="layui-input-block">
                <th:block th:each="value,iterStat: ${diy['state_type']}">
                        <input th:if="${iterStat.index == 0}"  type="radio" name="isState" th:value="${value.dictionaryRoute}" th:title="${value.dictionaryName}"  checked  >
                        <input th:if="${iterStat.index != 0}"  type="radio" name="isState" th:value="${value.dictionaryRoute}" th:title="${value.dictionaryName}">
                </th:block>
            </div>
        </div>

        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label">内容</label>
            <div class="layui-input-block">
                <textarea id="editor" type="text/plain" hidden="true" autofocus></textarea>
            </div>
        </div>

        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn" lay-submit lay-filter="edit">立即提交</button>
                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
            </div>
        </div>
    </form>
</div>
<div th:include="include::onload"></div>
<!--css引用-->
<link rel="stylesheet" type="text/css" th:href="@{/smiditor/styles/simditor.css}" />
<!--js引用-->
<script type="text/javascript" th:src="@{/smiditor/scripts/module.js}"></script>
<script type="text/javascript" th:src="@{/smiditor/scripts/hotkeys.js}"></script>
<script type="text/javascript" th:src="@{/smiditor/scripts/uploader.js}"></script>
<script type="text/javascript" th:src="@{/smiditor/scripts/simditor.js}"></script>

    <script  th:inline="javascript">
    layui.config({
        base: '/js/layer/module/'//模块存放的目录
    }).use(['form','verify'], function(){
        var form = layui.form;
        // 监听提交
        form.on('submit(edit)', function(data) {
            var content = $(".simditor-body").html();
            data.field.content = content;
            $.achieve.post("/admin/basics/bulletin/add",data.field,"",true);
            return false;
        });

    });

$(function(){
    Simditor.locale = 'zh-CN';//设置中文
    var editor = new Simditor({
        textarea: $("#editor"),  //textarea的id
        placeholder: '',
        toolbar:  ['title', 'bold', 'italic', 'underline', 'strikethrough', 'fontScale', 'color', '|', 'ol', 'ul', 'blockquote', 'code', 'table', '|', 'link', 'hr', '|', 'indent', 'outdent', 'alignment'], //工具条都包含哪些内容
    });
});
</script>

</body>
</html>